﻿// Inner Fire 游戏引擎库
// TreeSprite - 树木公告牌
//
// Copyright (c) 2025 by 尔西大帝. All rights reserved.
//
// 所属层级：元素层（3）
// 使用公告牌技术进行树木的绘制。
//
// Author: 尔西大帝
// Email: 2670613871@qq.com
// Created: 2025-01-13

#pragma once

#include <dx/core/dx_core.h>
#include <dx/mesh/dx_mesh.h>

namespace ifire::dx {

// 用于树的结构
struct TreeSpriteVertex {
  DirectX::XMFLOAT3 Pos;
  DirectX::XMFLOAT2 Size;

  TreeSpriteVertex(DirectX::XMFLOAT3 pos, DirectX::XMFLOAT2 size)
      : Pos(pos), Size(size) {}
};

class TreeSprite {
public:
  TreeSprite();
  TreeSprite(const TreeSprite& lhs) = delete;
  TreeSprite& operator=(const TreeSprite& lhs) = delete;
  ~TreeSprite() = default;

  DxMesh* Mesh() const { return mesh_.get(); }

  void Add(DirectX::XMFLOAT3 pos, DirectX::XMFLOAT2 size);
  void BuildMesh(ID3D12Device* device, ID3D12GraphicsCommandList* cmd_list);

private:
  std::unique_ptr<DxMesh> mesh_ = nullptr;
  eastl::vector<TreeSpriteVertex> vertices_;
};

} // namespace ifire::dx